package com.jial08.designpatterns.strategy;

import com.jial08.designpatterns.strategy.impl.CashNormal;
import com.jial08.designpatterns.strategy.impl.CashRebate;
import com.jial08.designpatterns.strategy.impl.CashReturn;

/**
 * <p>类描述：策略与简单工厂结合。</p>
 *
 * @author jl
 * @version v1.0.0.1。
 * @since JDK1.8。
 * <p>创建日期：2019/10/15 上午11:59。</p>
 */
public class CashContext {
	private Cash cash;

	CashContext(Type type, Double rebate, Double moneyCondition, Double moneyReturn) {
		switch (type) {
			case NORMAL:
				cash = new CashNormal();
				break;
			case REBATE:
				cash = new CashRebate(rebate);
				break;
			case RETURN:
				cash = new CashReturn(moneyCondition, moneyReturn);
				break;
			default:
				cash = null;
		}
	}

	public double getResult(double money) {
		return cash.acceptCash(money);
	}
}
